/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sys.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import sys.bean.StatusBean;
import sys.utils.ConexaoMySql;

/**
 *
 * @author Administrador
 */
public class StatusDao { 

    public List<StatusBean> listaStatus() throws SQLException {
        List<StatusBean> listStatus = new ArrayList<>();
        Connection con = ConexaoMySql.getConection();

        String sql = "SELECT s.id_status, s.descricao\n"
                + "FROM status s ";

        PreparedStatement stmt = con.prepareStatement(sql);
        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            StatusBean status = new StatusBean();

            status.setIdStatus(rs.getInt("id_status"));
            status.setDescricao(rs.getString("descricao"));

            listStatus.add(status);
        }

        stmt.close();
        con.close();

        return listStatus;
    }

}
